import { extend, localize } from "vee-validate";
import { required, email, min, length, confirmed } from "vee-validate/dist/rules";

import zh from "vee-validate/dist/locale/zh_CN.json";

extend("odd", value => {
  if (value % 2 !== 0) {
    return true;
  }

  return "请输入一个偶数";
});

extend("required", required);
extend("email", email);
extend("min", min);
extend("length", length);
extend("confirmed", confirmed);

localize("zh-CN", {
  messages: {
    ...zh.messages,
    required: "请输入{_field_}"
  },
  names: {
    email1111: "邮箱",
    password: "密码",
    repass: "确认密码",
    confirmPass: "确认密码aaa",
    name: "昵称",
    username: "账号",
    vercode: "验证码"
  },
  fields: {
    // 这里的规则会覆盖前面messages参数里面定义的提示
    email1111: {
      email: "请输入正确的{_field_}",
      required: "请输入{_field_}!!!"
    }
  }
});
